
#import "client_dataViewController.h"

@implementation client_dataViewController


/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

	NSLog(@"[  init  ] query init -----------------------------------------");
//	[Query init:@"192.168.1.2" port:3601];
	[Query init:@"59.66.130.136" port:10020];

// get version
	NSLog(@"[  test  ] get version ------------------------------------------");
	int version=[Query getVersion];
	NSLog(@"version %d: ",version);

// list menu
	NSLog(@"[  test  ] list menu ------------------------------------------");
	NSArray *menus=[Query listMenu];
	for(int i=0;i<[menus count];i++){
		Menu * m=(Menu *)[menus objectAtIndex:i];
		NSLog(@"menu %d: %@ %@ %@ %@ %@ %@ %@ %@ %@ ",i,m.menuId,m.name,m.price,m.description,m.rank,m.origPic,m.thumbPic,m.onsale,m.startSaleTime);
	}

// list category
	NSLog(@"[  test  ] list category ------------------------------------------");
	NSArray *cates=[Query listCategory];
	for(int i=0;i<[cates count];i++){
		Category *c=(Category *)[cates objectAtIndex:i];
		NSLog(@"category %d: %@ %@",i,c.catId,c.name);
	}

// start table
	NSLog(@"[  test  ] start table------------------------------------------");
	int st=[Query startTable:280];
	NSLog(@"start table: state is %d",st);

// submit order
	NSLog(@"[  test  ] submit order------------------------------------------");
	Order *order=[[Order alloc] init];
	order.desknum=[NSNumber numberWithInt:1000];
	order.menus=[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:15],@"0",[NSNumber numberWithInt:100],@"1",nil];
	int st2=[Query submitOrder:order];
	NSLog(@"submit order: state is %d",st2);

// get order
	NSLog(@"[  test  ] submit order------------------------------------------");
	Order * odr=[Query getOrder:280];
	NSLog(@"%@ %@ %@ %@ %@ %@ ",odr.orderId,odr.createTime,odr.updateTime,odr.desknum,odr.totalCost,odr.menus);

// update order
	NSLog(@"[  test  ] update order------------------------------------------");
	int st3=[Query updateOrder:odr];
	NSLog(@"update order: state is %d",st3);

// finish
	[Query finish];
	NSLog(@"[ finish ] query ---------------------------------------------");
}

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
